import { axios } from '@/utils/request'

const api = {
  finance: '/finance',
  financeStatistics: '/finance/statistics'
}

export function getProfitStatistics (params) {
  return axios({
    url: api.financeStatistics + '/profit',
    method: 'get',
    responseType: params.hasOwnProperty('export') ? 'blob' : 'json', // 导出 下载
    params
  })
}

export function getDailyReportStatistics (params) {
  return axios({
    url: api.financeStatistics + '/daily-report',
    method: 'get',
    responseType: params.hasOwnProperty('export') ? 'blob' : 'json', // 导出 下载
    params
  })
}

export function getDailyRewardList (params) {
  return axios({
    url: api.financeStatistics + '/daily-reward',
    method: 'get',
    params
  })
}

export function approvalOfDailyAwards (data) {
  return axios({
    url: api.financeStatistics + '/daily-reward',
    method: 'post',
    data
  })
}

export function getMonthlyRewardList (params) {
  return axios({
    url: api.financeStatistics + '/monthly-reward',
    method: 'get',
    params
  })
}

export function approvalOfMonthlyAwards (data) {
  return axios({
    url: api.financeStatistics + '/monthly-reward',
    method: 'post',
    data
  })
}

export function getCultivationAwardList (params) {
  return axios({
    url: api.financeStatistics + '/cultivation-award',
    method: 'get',
    responseType: params.hasOwnProperty('export') ? 'blob' : 'json', // 导出 下载
    params
  })
}

export function getAfterSaleCompensation (params) {
  return axios({
    url: api.financeStatistics + '/after-sale-compensation',
    method: 'get',
    responseType: params.hasOwnProperty('export') ? 'blob' : 'json', // 导出 下载
    params
  })
}

export function getWithdrawalsRecordList (params) {
  return axios({
    url: api.finance + '/withdrawals-record',
    method: 'get',
    responseType: params.hasOwnProperty('export') ? 'blob' : 'json', // 导出 下载
    params
  })
}

export function approveWithdrawals (data) {
  return axios({
    url: api.finance + '/withdrawals-record/approve',
    method: 'post',
    data
  })
}

export function getFinanceList (params) {
  return axios({
    url: api.finance + '/financial-details',
    method: 'get',
    responseType: params.hasOwnProperty('export') ? 'blob' : 'json', // 导出 下载
    params
  })
}
